<?php
class Session {
	protected static $protect;
	protected static $instance;
	function __construct() {
		if (Session::$instance === NULL) {
			$this->create ();
		}
		Session::$instance = $this;
	}
	function create() {
		$this->destroy ();
		session_name ( SESSION_NAME );
		session_start ();
		$_SESSION ['session_id'] = session_id ();
	}
	public function id() {
		return $_SESSION ['session_id'];
	}
	public function set($keys, $val = FALSE) {
		if (empty ( $keys ))
			return FALSE;
		if (! is_array ( $keys )) {
			$keys = array ($keys => $val );
		}
		foreach ( $keys as $key => $val ) {
			if (isset ( Session::$protect [$key] ))
				continue;
			$_SESSION [$key] = $val;
		}
	}
	public function destroy() {
		if (session_id () !== '') {
			// Get the session name
			$name = session_name ();
			
			// Destroy the session
			session_destroy ();
			
			// Re-initialize the array
			$_SESSION = array ();
			
			// Delete the session cookie
			cookie::delete ( $name );
		}
	}
}

?>